home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / mweb / MWEB Utils / ws295sdk.exe / Ws2sdkzp.exe / SAMPLES / LAYERED / DCATITEM.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-06  |  6.8 KB  |  306 lines

  1. /*++
  2.  
  3.      Copyright (c) 1996 Intel Corporation
  4.      Copyright (c) 1996 Microsoft Corporation
  5.      All Rights Reserved
  6.  
  7.      Permission is granted to use, copy and distribute this software and
  8.      its documentation for any purpose and without fee, provided, that
  9.      the above copyright notice and this statement appear in all copies.
  10.      Intel makes no representations about the suitability of this
  11.      software for any purpose.  This software is provided "AS IS."
  12.  
  13.      Intel specifically disclaims all warranties, express or implied,
  14.      and all liability, including consequential and other indirect
  15.      damages, for the use of this software, including liability for
  16.      infringement of any proprietary rights, and including the
  17.      warranties of merchantability and fitness for a particular purpose.
  18.      Intel does not assume any responsibility for any errors which may
  19.      appear in this software nor any responsibility to update it.
  20.  
  21.  
  22. Module Name:
  23.  
  24.     dcatitem.cpp
  25.  
  26. Abstract:
  27.  
  28.     This  file  contains  the  class  implementation for the PROTO_CATALOG_ITEM
  29.     class.   This  class  defines  the  interface  to  the  entries that can be
  30.     retrieved from the protocol catalog.
  31.  
  32. --*/
  33.  
  34.  
  35. #include "precomp.h"
  36.  
  37.  
  38. PROTO_CATALOG_ITEM::PROTO_CATALOG_ITEM()
  39. /*++
  40.  
  41. Routine Description:
  42.  
  43.     This  procedure  constructs  an empty PROTO_CATALOG_ITEM object.  The first
  44.     method  invoked  after  this  constructor must be Initialize().
  45.  
  46. Arguments:
  47.  
  48.     None
  49.  
  50. Return Value:
  51.  
  52.     Implicitly  returns  a pointer to a newly created PROTO_CATALOG_ITEM object
  53.     or NULL if there is a memory allocation failure.
  54. --*/
  55. {
  56.     DEBUGF(
  57.         DBG_TRACE,
  58.         ("PROTO_CATALOG_ITEM constructor\n"));
  59.  
  60.     // Simply initialize embedded pointer values for safety.
  61.     m_LibraryPath[0] = '\0';
  62.     m_Provider = NULL;
  63.     m_ProviderCatalogEntry = NULL;
  64. }  // PROTO_CATALOG_ITEM
  65.  
  66.  
  67.  
  68.  
  69.  
  70. INT
  71. PROTO_CATALOG_ITEM::Initialize(
  72.     IN  LPWSAPROTOCOL_INFOW  ProtoInfo
  73.     )
  74. /*++
  75.  
  76. Routine Description:
  77.  
  78.     This  procedure initializes the protocol info part of the catalog item from
  79.     the  values  supplied.  Values are copied from the structures passed by the
  80.     caller,  so  the  caller  is  free  to  deallocate the passed structures on
  81.     return.
  82.  
  83. Arguments:
  84.  
  85.     ProtoInfo    - Supplies  a reference to the fully initialized protocol info
  86.                    structure describing this protocol.
  87.  
  88. return Value:
  89.  
  90.     The  function  returns ERROR_SUCCESS if successful, otherwise it returns an
  91.     appropriate WinSock error code.
  92.  
  93. --*/
  94. {
  95.     INT ReturnValue = ERROR_SUCCESS;
  96.     INT BufferSize  = sizeof(m_LibraryPath);
  97.  
  98.     // Copy ProtoInfo
  99.     m_ProtoInfo = *ProtoInfo;
  100.  
  101.     // Get the LibraryPath
  102.     gUpCallTable.lpWPUGetProviderPath(
  103.         &ProtoInfo->ProviderId,
  104.         (WCHAR*)&m_LibraryPath,
  105.         &BufferSize,
  106.         &ReturnValue);
  107.  
  108.     if (ERROR_SUCCESS != ReturnValue){
  109.         m_LibraryPath[0] = '\0';
  110.     } //if
  111.  
  112.     return (ReturnValue);
  113.  
  114. }  // Initialize
  115.  
  116.  
  117.  
  118.  
  119. PROTO_CATALOG_ITEM::~PROTO_CATALOG_ITEM()
  120. /*++
  121.  
  122. Routine Description:
  123.  
  124.     This  procedure  destroys  a  protocol catalog item, deallocating memory it
  125.     owns.   It  is the caller's responsibility to remove the item from the list
  126.     it  occupies  before  calling  this  procedure.   It  is  also the caller's
  127.     responsibility  to unload and/or destroy any dprovider associated with this
  128.     catalog item if appropriate.
  129.  
  130. Arguments:
  131.  
  132.     None
  133.  
  134. Return Value:
  135.  
  136.     None
  137. --*/
  138. {
  139.     m_LibraryPath[0] = '\0';
  140. }  // ~PROTO_CATALOG_ITEM
  141.  
  142.  
  143.  
  144.  
  145. LPWSAPROTOCOL_INFOW
  146. PROTO_CATALOG_ITEM::GetProtocolInfo()
  147. /*++
  148.  
  149. Routine Description:
  150.  
  151.     This  procedure  retrieves a reference to the protocol info associated with
  152.     the  catalog  item.   Note  that  the  reference is to storage owned by the
  153.     catalog item.  It is the caller's responsibility to make sure the reference
  154.     is no longer used after the catalog item is destroyed.
  155.  
  156. Arguments:
  157.  
  158.     None
  159.  
  160. Return Value:
  161.  
  162.     Returns a pointer to the associated protocol info.
  163. --*/
  164. {
  165.     assert(m_LibraryPath[0] != '\0');
  166.     return(& m_ProtoInfo);
  167. }  // GetProtocolInfo
  168.  
  169.  
  170.  
  171.  
  172. PWCHAR
  173. PROTO_CATALOG_ITEM::GetLibraryPath()
  174. /*++
  175.  
  176. Routine Description:
  177.  
  178.     This    procedure   retrieves   a   reference   to   the   zero-terminated,
  179.     fully-qualified  path  of  the library that is the service provider for the
  180.     protocol  associated  with the catalog item.  Note that the reference is to
  181.     storage  owned  by  the catalog item.  It is the caller's responsibility to
  182.     make  sure  the  reference  is  no  longer  used  after the catalog item is
  183.     destroyed.
  184.  
  185. Arguments:
  186.  
  187.     None
  188.  
  189. Return Value:
  190.  
  191.     Returns a pointer to the library path string.
  192. --*/
  193. {
  194.     assert(m_LibraryPath[0] != '\0');
  195.     return(m_LibraryPath);
  196. }  // GetLibraryPath
  197.  
  198.  
  199.  
  200.  
  201. VOID
  202. PROTO_CATALOG_ITEM::SetProviderCatalogEntry(
  203.     IN  PPROTO_CATALOG_ITEM  CatalogEntry
  204.     )
  205. /*++
  206.  
  207. Routine Description:
  208.  
  209.     This procedure sets the PPROTO_CATALOG_ENTRY
  210.  
  211. Arguments:
  212.  
  213.     Provider - Supplies the new catalog entry reference.
  214.  
  215. Return Value:
  216.  
  217.     None
  218. --*/
  219. {
  220.     if (m_ProviderCatalogEntry != NULL) {
  221.         DEBUGF(
  222.             DBG_WARN,
  223.             ("Suspicious - overwriting a catalog entry reference\n"));
  224.     }
  225.     m_ProviderCatalogEntry = CatalogEntry;
  226. }  // SetProviderCatalogEntry
  227.  
  228.  
  229. VOID
  230. PROTO_CATALOG_ITEM::SetProvider(
  231.     IN  PDPROVIDER  Provider
  232.     )
  233. /*++
  234.  
  235. Routine Description:
  236.  
  237.     This procedure sets the DPROVIDER associated with a catalog entry.
  238.  
  239. Arguments:
  240.  
  241.     Provider - Supplies the new DPROVIDER reference.
  242.  
  243. Return Value:
  244.  
  245.     None
  246. --*/
  247. {
  248.     if (m_Provider != NULL) {
  249.         DEBUGF(
  250.             DBG_WARN,
  251.             ("Suspicious - overwriting a dprovider reference\n"));
  252.     }
  253.     m_Provider = Provider;
  254. }  // SetProvider
  255.  
  256.  
  257.  
  258.  
  259.  
  260. PDPROVIDER
  261. PROTO_CATALOG_ITEM::GetProvider()
  262. /*++
  263.  
  264. Routine Description:
  265.  
  266.     This  procedure  retrieves  a  reference to the DPROVIDER associated with a
  267.     catalog  entry.  Note that the reference may be NULL if no provider has yet
  268.     been loaded for this protocol.
  269.  
  270. Arguments:
  271.  
  272.     None
  273.  
  274. Return Value:
  275.  
  276.     Returns  the  current provider reference, or NULL if there is no associated
  277.     provider.
  278. --*/
  279. {
  280.     return(m_Provider);
  281. }  // GetProvider
  282.  
  283.  
  284. PPROTO_CATALOG_ITEM
  285. PROTO_CATALOG_ITEM::GetProviderCatalogEntry()
  286. /*++
  287.  
  288. Routine Description:
  289.  
  290.     This  procedure  retrieves  a  reference to the protocol catalog entry associated with a
  291.     catalog  entry.  Note that the reference may be NULL if no provider has yet
  292.     been loaded for this protocol.
  293.  
  294. Arguments:
  295.  
  296.     None
  297.  
  298. Return Value:
  299.  
  300.     Returns  the  current provider catalog entry reference, or NULL if there is no associated
  301.     provider.
  302. --*/
  303. {
  304.     return(m_ProviderCatalogEntry);
  305. }
  306.